﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using Entity;

namespace Data
{
    public class ToDoContext : DbContext
    {
        public ToDoContext()
        {  
            this.Configuration.LazyLoadingEnabled = true;     
        }  
  

        public DbSet<ToDo> ToDos { get; set; }

        public DbSet<Project> Projects { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Project>()
            .HasMany(p => p.ToDos)
            .WithRequired(t => t.Project);
            base.OnModelCreating(modelBuilder);

        } 
    }
}
